//服务指南、关于我们的数据加载
import LoadTopicPageDataMixin from "@/mixins/LoadTopicPageDataMixin";
import {getResource} from "@/api/CommonApi"

export default{
    name:'WatchParamsLoadPageDataMixin',
    mixins:[
        LoadTopicPageDataMixin
    ],
    data(){
        return{
            //专辑数据
            albumData:{}
        }
    },
    created(){
        this.setPageSize(10);
        //设置获取数据的code
        console.log("this.$route.params.identity = ", this.$route.params.identity);
        this.setPageDataCode(this.$route.params.identity);
        //加载数据
        this.loadPageData(1).then(() => {
            console.log("this.pageData = ", this.pageData);
            const id = this.pageData.records[0].id;
            getResource(id).then(res => {
                this.albumData = res.result;
                console.log("this.albumData : ", this.albumData);
                //html内容
                const htmlContent = this.albumData.firstItem.content;
                document.getElementById("html-content-box").innerHTML = htmlContent;
            });
        });

    },

    watch:{
        $route(){
            this.setPageSize(10);
            //设置获取数据的code
            console.log("this.$route.params.identity = ", this.$route.params.identity);
            this.setPageDataCode(this.$route.params.identity)
            //加载数据
            this.loadPageData(1).then(() => {
                const id = this.pageData.records[0].id;
                getResource(id).then(res => {
                    this.albumData = res.result;
                    console.log("this.albumData : ", this.albumData);
                    //html内容
                    const htmlContent = this.albumData.firstItem.content;
                    document.getElementById("html-content-box").innerHTML = htmlContent;
                });
            });

        }
    }

}